﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Enterprise.Infrastructure;
using Enterprise.Model.BusiTravel;
using Enterprise.Service.BusiTravel;
namespace Enterprise.UI.Web.Modules.BusiTravel
{
    public partial class Index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                OnBindAll();
                OnBindUser();
            }
        }
        private void OnBindAll()
        {
            BusiTravelService bService = new BusiTravelService();
            List<BusiTravelEntity> list = bService.BusiTravelList().Where(p => p.BSTATE == 1 && p.BCLOSE == 0).ToList();
            GridView2.DataSource = list;
            GridView2.DataBind();
        }

        private void OnBindUser()
        {
            BusiTravelService bService = new BusiTravelService();
            List<BusiTravelEntity> list = bService.BusiTravelList().Where(p=>p.USERID==Utility.Get_UserId).ToList();
            GridView1.DataSource = list;
            GridView1.DataBind();
        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView1.PageIndex = e.NewPageIndex;
            OnBindUser();
        }

        protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            GridView2.PageIndex = e.NewPageIndex;
            OnBindAll();
        }

    }
}